//
//  BYJManageViewController.m
//  BLDMusics
//
//  Created by 白云杰 on 16/3/22.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "BYJManageViewController.h"

@interface BYJManageViewController ()<UITableViewDataSource, UITableViewDelegate>

/** tableView */
@property (nonatomic, retain) UITableView *manageTableView;
/** 选择的图片 */
@property (nonatomic, retain) UIImageView *imgView;
@property (nonatomic, assign) BOOL select;

@end

@implementation BYJManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self createTabelView];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"list_menu_download"] style:UIBarButtonItemStyleDone target:self action:@selector(itemAction:)];
    self.navigationItem.rightBarButtonItem = item;
    
    _select = NO;
}

- (void)itemAction:(UIBarButtonItem *)item {
    
}

- (void)createTabelView {
    
    self.manageTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH - 64 - 49) style:UITableViewStylePlain];
    _manageTableView.backgroundColor = [UIColor whiteColor];
    _manageTableView.delegate = self;
    _manageTableView.dataSource = self;
    _manageTableView.separatorStyle = UITableViewCellAccessoryNone;
    [self.view addSubview:_manageTableView];
    
    [_manageTableView registerClass:[BYJManageTableViewCell  class] forCellReuseIdentifier:@"BYJManageTableViewCell"];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return (SCREEN_HEIGTH - 113) / 8;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    BYJManageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BYJManageTableViewCell" forIndexPath:indexPath];
    BYJsongListModel *model = _dataSource[indexPath.row];
    cell.model = model;

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    BYJManageTableViewCell *cell = (BYJManageTableViewCell*)[_manageTableView cellForRowAtIndexPath:indexPath];
    BYJsongListModel *model = _dataSource[indexPath.row];
    
    if (model.isSelect == NO) {
        
        model.isSelect = YES;
        cell.imgView.image = [UIImage imageNamed:@"list_edit_selected"];
    } else {
        
        model.isSelect = NO;
        cell.imgView.image = [UIImage imageNamed:@"list_edit_unselected"];
    }
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
